﻿using RegressionByWinForm.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RegressionByWinForm
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 用于选择X序列的文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            //按下按钮1之后显示选择文件对话框
            this.openFileDialogX.ShowDialog();
            this.lbXFilePath.Text = this.openFileDialogX.FileName;
        }
        /// <summary>
        /// 用于选择Y序列的文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            //按下按钮2之后选择文件对话框
            this.openFileDialogY.ShowDialog();
            this.lbYFilePath.Text = this.openFileDialogY.FileName;
        }

        /// <summary>
        /// 用于预测
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnForecast_Click(object sender, EventArgs e)
        {
            double gdp = MyMainFunctions.ForecastFunctions(lbXFilePath.Text, lbYFilePath.Text, double.Parse(txbInputYear.Text));
            txbForecastGdp.Text = $"预测{double.Parse(txbInputYear.Text)}年的GDP为{gdp.ToString("##.##")}亿元";
        }

        #region 用不到的
        private void openFileDialogX_FileOk(object sender, CancelEventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }



        private void label1_Click_1(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click_1(object sender, EventArgs e)
        {

        }



        private void frmMain_Load(object sender, EventArgs e)
        {

        }

        private void txbShowAB_TextChanged(object sender, EventArgs e)
        {

        }
        #endregion
    }
}
